package grpc

import (
	"flag"
	"fmt"
	"google.golang.org/grpc"
	"log"
	"net"
	"zg4/zk1/server/internal/handler"
	__ "zg4/zk1/server/proto"
)

func Grpc() {
	flag.Parse()
	lis, err := net.Listen("tcp", fmt.Sprintf(":%d", 8899))
	if err != nil {
		log.Fatalf("failed to listen: %v", err)
	}
	s := grpc.NewServer()

	__.RegisterVideoServer(s, &handler.Server{})
	log.Printf("server listening at %v", lis.Addr())
	if err := s.Serve(lis); err != nil {
		log.Fatalf("failed to serve: %v", err)
	}
}
